/**
 * Copyright (C) 2008 GeoScheduler Team, as stated on <http://www.geoscheduler.org/authors>.
 * 
 * This file is part of GeoScheduler.
 * 
 * GeoScheduler is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * GeoScheduler is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with GeoScheduler. If not, see <http://www.gnu.org/licenses/>.
 */

package org.geoscheduler.model.dto;

import java.util.Date;

import org.geoscheduler.commons.marshaller.JSONField;
import org.geoscheduler.model.Account;

/**
 * Data transfer object for event queries.
 * Used to transfer query in REST requests.
 *
 * @author srakyi
 */
public class EventQueryDTO {
	
	private Account account;
	
	private int lat;
	private int lon;
	
	private Date timeFrom;
	private Date timeTo;

	private int offset;
	private int maxResults;
	
	public Account getAccount() {
		return account;
	}
	
	public long getIdAccount() {
		if (account != null) {
			return account.getId();
		} else {
			return 0;
		}
	}

	public void setAccount(Account account) {
		this.account = account;
	}
	
	@JSONField
	public int getLat() {
		return lat;
	}

	public void setLat(int lat) {
		this.lat = lat;
	}

	@JSONField
	public int getLon() {
		return lon;
	}

	public void setLon(int lon) {
		this.lon = lon;
	}

	@JSONField
	public Date getTimeFrom() {
		return timeFrom;
	}

	public void setTimeFrom(Date timeFrom) {
		this.timeFrom = timeFrom;
	}

	@JSONField
	public Date getTimeTo() {
		return timeTo;
	}

	public void setTimeTo(Date timeTo) {
		this.timeTo = timeTo;
	}

	@JSONField
	public int getOffset() {
		return offset;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}

	// FIXME default values doesn't work now, we have to use small hack instead
	@JSONField(Null=false,defaultValue="1000")
	public int getMaxResults() {
		if (maxResults == 0) {
			return 1000;
		} else {
			return maxResults;
		}
	}

	public void setMaxResults(int maxResults) {
		this.maxResults = maxResults;
	}
}
